//
//  _iOSUtils_Classes.m
//  iOSUtils
//
//  Created by HJC on 11-9-8.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "_iOSUtils_Classes.h"


/////////////////////////////////////////
#pragma mark NSSingleton类
@implementation NSSingleton

- (id)copyWithZone:(NSZone *)zone
{
    return self;
}

- (id)retain 
{
    return self;
}

- (NSUInteger)retainCount 
{
    return UINT_MAX;  // denotes an object that cannot be released
}

- (void)release 
{
    //do nothing
}

- (id)autorelease 
{
    return self;
}


+ (void)  generateInstanceIfNeed:(NSObject**)sharedInstance
{
    if (*sharedInstance == nil)
    {
        @synchronized(self)
        {
            if (*sharedInstance == nil)
            {
                *sharedInstance = [[self alloc] init];
            }
        }
    }
}

@end



////////////////////////////////////////////////
@implementation NSPair
@synthesize objA = _objA;
@synthesize objB = _objB;

- (void) dealloc
{
    [_objA release];
    [_objB release];
    [super dealloc];
}


- (id) initWithObjA:(NSObject*)oA objB:(NSObject*)oB
{
    self = [super init];
    if (self)
    {
        _objA = [oA retain];
        _objB = [oA retain];
    }
    return self;
}


+ (id) pairWithObjA:(NSObject*)oA objB:(NSObject*)oB 
{
    return [[[self alloc] initWithObjA:oA objB:oB] autorelease];
}


@end
